package com.ruix.app.ui.adapter;

import android.content.Context;

import com.ruix.app.R;
import com.ruix.app.adapter.superadapter.SuperAdapter;
import com.ruix.app.adapter.superadapter.internal.SuperViewHolder;
import com.ruix.app.model.FeedbackAdvice;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by hadexs on 2017/4/29.
 */

public class FeedbackListAdapter extends SuperAdapter<FeedbackAdvice>{

    private SimpleDateFormat format;
    private Date date;

    public FeedbackListAdapter(Context context) {
        super(context, R.layout.item_feedback_list);
    }

    @Override
    public void onBind(SuperViewHolder holder, int viewType, int position, FeedbackAdvice item) {
        holder.setText(R.id.tv_feedback_content,item.getContent());
        holder.setText(R.id.tv_feedback_time,buildCreatTime(item.getCreatedTime()));



    }

    public String buildCreatTime(long ceratedTime){
        if (format == null) {
            format = new SimpleDateFormat("yyyy年MM月dd日");
        }
        if (date == null) {
            date = new Date(ceratedTime);
        } else {
            date.setTime(ceratedTime);
        }
       return format.format(date);
    }
}
